<html>
    <head>
        <title>类的继承</title>

        <script type="text/javascript">

            //1. 定义基类
            class Point{
                _x = 0;
                _y = 0;
                constructor(x=0.0, y=0.0){
                    this._x = x;
                    this._y = y; 
                }

                get X(){
                    return this._x;
                }

                set X(x){
                    this._x = x;
                }
                
                get Y(){
                    return this._y;
                }

                set Y(y){
                    this._y = y;
                }

                distance(pt){
                    return Math.sqrt(Math.pow(this._x-pt.X, 2.0)+Math.pow(this._y-pt.Y, 2.0));
                }
            }

            //2. 定义派生类
            class GeoPoint extends Point{
                //2.1 定义派生类的属性
                _srid = "";
                
                constructor(x, y, srid){
                    //2.2 调用基类的构造函数
                    super(x, y);
                    //2.3 初始化派生类属性
                    this._srid = srid;
                }
            }

            function init(){
                let gp = new GeoPoint(116,39,"EPSG:4326");
                alert(gp.X);
            }
        </script>
    </head>
    <body onload="init()"></body>
</html>